<?php
/**
 * Created by PhpStorm
 * USER MingTingLiang   QQ 915802070
 * Date 2020-12-17-017   15:38
 */
require "commonds/ICommond.php";
require "commonds/SaveToDB.php";
require "commonds/SaveToMemcached.php";
require "commonds/GenFIle.php";

class  NewsModel
{
    public $ormData = null;

    public function __construct($activeRecorder)
    {
        $this->ormData = $activeRecorder;
    }

    public function commit(...$commonds)
    {
        foreach ($commonds as $index => $commond) {
            if (is_subclass_of($commond, 'ICommond')) {
                if (!$commond->isRemoved) {
                    $commond->exec($this->ormData);
                }
            }
        }
    }
}

$newsModel = new NewsModel(null);

$saveToDB = new SaveToDB();
$mem = new SaveToMemcached();


$newsModel->commit(new SaveToDB(), new SaveToMemcached(), new GenFIle());

?>

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<form action="" method="post">
    <tr>
        标题 <input type="text" name="text">
    </tr>
    <tr>
        内容: <textarea name="" id="" cols="30" rows="10"></textarea>
    </tr>
    <button>提交</button>
</form>
</body>
</html>